<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <style>
        *{
            list-style: none;
        }
        ul{
            width: 300px;
            background-color: #fff;
            position: relative;
            border-bottom: 1px solid #ccc;
        }
        ul li{
            float: left;
        }
        a{
            float:right;
        }
    </style>
</head>
<body>
    <div class="container">
        <textarea name="" id="" cols="30" rows="10"></textarea>
        <button class="btn btn-default">提交</button>
        <ul></ul>
    </div>
    <script>
        var txt=document.querySelector('textarea');
        var btn=document.querySelector('button');
        var ul=document.querySelector('ul');
        btn.addEventListener('click',function(){
            if(txt.value==''){
                alert('请输入内容');
                return false;
            }else{
                var li=document.createElement('li');
                li.innerHTML=txt.value + '<a href="#" class="glyphicon glyphicon-remove"></a>' ;
                ul.insertBefore(li,ul.children[0]);
                txt.value="";
                var a=document.querySelectorAll('a')
                for(var i=0;i<a.length;i++){
                    a[i].addEventListener('click',function(){
                        ul.removeChild(li);
                    })
                }
            }
        })
    </script>
</body>
</html>